Use PushFilePreparer in apex-rollback-tests Calling remountSystemWritable to install test files on the system partition leaves the device in a state that could adversely effect subsequent tests run on the device. Switch to the more standard PushFilePreparer to set up the device rather than have to duplicate logic to restore the device to a good state after running the test. Bug: 140014856 Test: atest apex_rollback_tests Change-Id: I5d320d519d304485295613e297fc21cf470f0cba
diff --git a/tests/apex-rollback-tests.xml b/tests/apex-rollback-tests.xml index 5887448..211176a 100644 --- a/tests/apex-rollback-tests.xml +++ b/tests/apex-rollback-tests.xml
@@ -17,6 +17,12 @@ <option name="test-suite-tag" value="apex_rollback_tests" /> <option name="test-suite-tag" value="apct" /> <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/> + <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer"> + <option name="cleanup" value="true" /> + <option name="remount-system" value="true" /> + <option name="push" value="trigger_watchdog.rc->/system/etc/init/trigger_watchdog.rc" /> + <option name="push" value="trigger_watchdog.sh->/system/bin/trigger_watchdog.sh" /> + </target_preparer> <test class="com.android.tradefed.testtype.HostTest" > <option name="jar" value="apex_rollback_tests.jar" /> </test>
diff --git a/tests/src/com/android/tests/apex/ApexRollbackTests.java b/tests/src/com/android/tests/apex/ApexRollbackTests.java index 1471843..fd23f1d 100644 --- a/tests/src/com/android/tests/apex/ApexRollbackTests.java +++ b/tests/src/com/android/tests/apex/ApexRollbackTests.java
@@ -41,8 +41,6 @@ public class ApexRollbackTests extends BaseHostJUnit4Test { private static final String SHIM_APEX_PACKAGE_NAME = "com.android.apex.cts.shim"; - private static final String SYSTEM_TRIGGER_WATCHDOG_RC = "/system/etc/init/trigger_watchdog.rc"; - private static final String SYSTEM_TRIGGER_WATCHDOG_SH = "/system/bin/trigger_watchdog.sh"; /** * Uninstalls a shim apex only if its latest version is installed on /data partition (i.e. @@ -85,17 +83,6 @@ @After public void tearDown() throws Exception { uninstallShimApexIfNecessary(); - - // Only clean up the trigger watchdog files if they exist to avoid - // the extra boot loop needed in some cases to remount the system - // writable. - ITestDevice device = getDevice(); - if (device.doesFileExist(SYSTEM_TRIGGER_WATCHDOG_RC) - || device.doesFileExist(SYSTEM_TRIGGER_WATCHDOG_SH)) { - device.remountSystemWritable(); - device.deleteFile(SYSTEM_TRIGGER_WATCHDOG_RC); - device.deleteFile(SYSTEM_TRIGGER_WATCHDOG_SH); - } } /** @@ -113,8 +100,6 @@ assumeTrue("Device does not support updating APEX", isApexUpdateSupported()); ModuleTestUtils utils = new ModuleTestUtils(this); - File triggerWatchdogRcFile = utils.getTestFile("trigger_watchdog.rc"); - File triggerWatchdogShFile = utils.getTestFile("trigger_watchdog.sh"); File apexFile = utils.getTestFile("com.android.apex.cts.shim.v2.apex"); // To simulate an apex update that causes a boot loop, we install a @@ -125,9 +110,6 @@ // trigger_watchdog.sh repeatedly kills the system server causing a // boot loop. ITestDevice device = getDevice(); - device.remountSystemWritable(); - device.pushFile(triggerWatchdogRcFile, SYSTEM_TRIGGER_WATCHDOG_RC); - device.pushFile(triggerWatchdogShFile, SYSTEM_TRIGGER_WATCHDOG_SH); device.setProperty("persist.debug.trigger_watchdog.apex", "com.android.apex.cts.shim@2"); String error = device.installPackage(apexFile, false); assertThat(error).isNull();